#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;

int n, m;
int np[N];
int primes[N], phi[N], tot;
ll ans[N];
void init(int n) {
  np[1] = 1;
  phi[1] = 1;
  rep(i, 2, n) {
    if (!np[i]) {
      primes[++tot] = i;
      phi[i] = i - 1;
    }
    rep(j, 1, tot) {
      ll k = 1ll * primes[j] * i;
      if (k > n) break;
      np[k] = 1;
      phi[k] = phi[i] * ((i % primes[j]) ? primes[j] - 1 : primes[j]);
      if (i % primes[j] == 0) break;
    }
  }
  ans[1] = 3;
  rep(i, 2, n) ans[i] = ans[i - 1] + phi[i] * 2;
}

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  init(1000);
  int t;
  cin >> t;
  rep(id, 1, t) {
    int x;
    cin >> x;
    cout << id << ' ' << x << ' ' << ans[x] << endl;
  }

  return 0;
}